package xyz.xtt.pay.vo;

import java.math.BigDecimal;
import java.util.Objects;

import lombok.Builder;
import lombok.Data;
import xyz.xtt.pay.entity.PayOrder;

@Data
@Builder
public class OrderVo {

	private Long orderId;
	/**
	 * 支付状态： 0 -> 未支付 1 -> 已支付 2 -> 支付失败 3 -> 支付取消 4 -> 已退款
	 */
	private Integer payStatus;

	/**
	 * 订单金额
	 */
	private BigDecimal orderMoney;

	/**
	 * 实际支付金额
	 */
	private BigDecimal payMoney;

	/**
	 * 创建时间
	 */
	private Long createTime;
	/**
	 *
	 */
	private String goodsName;

	private String goodsId;
	private Long assetId;
	private String imageUrl;
	/* nft-展示类型 */
	private Integer firstType;
	/**
	 * 二级分类
	 */
	private Integer secondType;

	private Integer businessType;
	/** 关联业务ID */
	private String businessRefId;

	private String transportCompany;
	private String transportNo;

	private Integer purchaseNum;

	// public static OrderVo createOrderVo(TblAssetTransaction transaction) {
//		if (Objects.isNull(transaction)) {
//			return null;
//		}
//		return OrderVo
//				.builder()
//				.orderId(transaction.getOrderId())
//				.payStatus(transaction.getPayState())
//				.orderMoney(Objects.isNull(transaction.getOrderPrice()) ? BigDecimal.ZERO : transaction.getOrderPrice())
//				.payMoney(Objects.isNull(transaction.getOrderPrice()) ? BigDecimal.ZERO : transaction.getOrderPrice())
//				.createTime(transaction.getDealCreateDatetime())
//				.build();
//	}

	public static OrderVo createOrderVo(PayOrder payOrder) {
		if (Objects.isNull(payOrder)) {
			return null;
		}
		return OrderVo
				.builder()
				.orderId(payOrder.getPayOrderId())
				.payStatus(payOrder.getPayStatus())
				.orderMoney(Objects.isNull(payOrder.getOrderMoney()) ? BigDecimal.ZERO : payOrder.getOrderMoney())
				.payMoney(Objects.isNull(payOrder.getPayMoney()) ? BigDecimal.ZERO : payOrder.getPayMoney())
				.createTime(payOrder.getCreateTime())
				.businessType(payOrder.getBusinessType())
				.businessRefId(payOrder.getBusinessRefId())
				.build();
	}
}
